home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / programm.ing / ltmf_120.lzh / LET_INST.S < prev    next >
Encoding:
Text File  |  1993-04-13  |  21.1 KB  |  842 lines

  1. ****************************************************************************
  2. *
  3. *    Let 'em Fly! V1.2        Installing & Trap Part
  4. *
  5. *    (c) 1991-92 by Oliver Scheel
  6. *
  7. ****************************************************************************
  8.  
  9.         import    nap_exit,load_icons,get_cookie
  10.  
  11.         import    nfm_dial,nfm_do,nfm_button,nfm_keybd,nfm_center
  12.         import    nfm_alert,nfm_error
  13.         import    nob_edit
  14.         import    menu_patch,niceline,init_niceline,nl_handle
  15.  
  16.         import    netv_critic
  17.  
  18.         import    di_fly,obj_clsize,init_keys,lookup_key
  19.         import    di_moveto,ins_spcchar,hist_insert,di_center
  20.         import    dialno,lasttree,lastdone,was_used
  21.  
  22.         import    vers,cpyright
  23.         import    aes,global
  24.  
  25.         export    letemfly
  26.         export    mousecnt,jacks_in,magx,aes_version
  27.  
  28.         export    new_trap2,old_trap2
  29.  
  30. ****************************************************************************
  31.  
  32. LIGHT        equ    0
  33. ETV_CRITIC    equ    1
  34.  
  35. XBRA_ID        equ    'LTMF'
  36.  
  37. ****************************************************************************
  38.  
  39. trap2v        equ    $88        ; AES/VDI Trap
  40. trap13v        equ    $b4        ; BIOS Trap
  41.  
  42. RESMAGIC    EQU    $31415926
  43. _resvalid    EQU    $0426
  44. _resvector    EQU    $042a
  45.  
  46. etv_critic    EQU    $0404
  47.  
  48. _p_cookies    EQU    $05a0
  49.  
  50. savptr        EQU    $04a2
  51. _sysbase    EQU    $04f2
  52.  
  53. MAXCOOKIE    EQU    20
  54.  
  55. ****************************************************************************
  56.  
  57. CFG_BYPASS    equ    0
  58. CFG_G_GROW    equ    1
  59. CFG_ALERT    equ    4
  60.  
  61. CFG_NICELN    equ    6
  62.  
  63. ****************************************************************************
  64.  
  65.         text
  66.  
  67. ****************************************************************************
  68. *    install
  69. ****************************************************************************
  70.  
  71. start:
  72.         movea.l 4(sp),a0        ; basepage address
  73.         move.l    #$100,a6        ; basepage lenght
  74.         add.l    12(a0),a6        ; add textlen
  75.         add.l    20(a0),a6        ; add datalen
  76.         add.l    28(a0),a6        ; add bsslen
  77.         move.l    a6,prglen        ; save length
  78.         move.l    a0,prgstart        ; save prgstart
  79.  
  80.         lea    my_stack,sp
  81.  
  82.         move.l    a6,-(sp)        ; new length
  83.         move.l    a0,-(sp)        ; beginning of block
  84.         clr.w    -(sp)            ; dummy
  85.         move.w    #$4a,-(sp)        ; Mshrink()
  86.         trap    #1            ; GEMDOS
  87.         lea    12(sp),sp
  88.  
  89.         bsr    vq_aes
  90.         tst.w    d0            ; AES already aktive ?
  91.         beq    skip2            ; no -> skip
  92.         move.w    #1,gem_inst
  93.  
  94. skip2:
  95.         lea    rvs_on,a0        ; reverse on
  96.         bsr    strout
  97.         move.l    vers,a0            ; version
  98.         addq.l    #4,a0
  99.         bsr    strout
  100.         lea    rvs_off,a0        ; reverse off
  101.         bsr    strout
  102.         move.l    cpyright,a0        ; copyright
  103.         bsr    strout
  104.         lea    freaky,a0        ; Freaky Deaky
  105.         bsr    strout
  106.  
  107.         pea    install            ; install new routines
  108.         move.w    #38,-(sp)        ; Supexec()
  109.         trap    #14            ; XBIOS
  110.         addq.l    #6,sp
  111.         tst.w    d0            ; test result
  112.         bne    skip3            ; fault -> cancel
  113.  
  114. .iff LIGHT
  115.         jsr    load_icons(pc)        ; load icons
  116.         tst.w    d0            ; test result
  117.         beq    skip5            ; FALSE -> no icons loaded
  118.         lea    ld_icons,a0        ; TRUE -> print message
  119.         bsr    strout
  120. .endif
  121. skip5:
  122.         pea    new_trap13        ; install TRAP #13 (BIOS)
  123.         move.w    #45,-(sp)        ; Exeption 45
  124.         move.w    #5,-(sp)        ; Setexc()
  125.         trap    #13
  126.         addq.l    #8,sp
  127.         move.l    d0,old_trap13        ; save old vector
  128.  
  129.         tst.w    gem_inst        ; AES isntalled
  130.         beq    skip4            ; no -> skip
  131.  
  132.         pea    new_trap2        ; install TRAP #2 (AES)
  133.         move.w    #34,-(sp)        ; Exeption 34
  134.         move.w    #5,-(sp)        ; Setexc()
  135.         trap    #13
  136.         addq.l    #8,sp
  137.         move.l    d0,old_trap2        ; save old vector
  138.  
  139. skip4:
  140. .if ETV_CRITIC
  141.         move.l    #'MagX',d0        ; looking for clues
  142.         jsr    get_cookie(pc)
  143.         move.l    a0,magx
  144.         bne    skip6            ; Mag!X available
  145.         bra    skip1
  146.  
  147. /*        move.l    #'MiNT',d0
  148.         jsr    get_cookie(pc)
  149.         cmp.l    #0,a0
  150.         beq    skip1
  151. */
  152. skip6:        move.l    a0,multi_aes
  153.         pea    new_etv_critic        ; install etv_critic handler
  154.         move.w    #257,-(sp)        ; Exception 257
  155.         move.w    #5,-(sp)        ; Setexc()
  156.         trap    #13
  157.         addq.l    #8,sp
  158.         move.l    d0,old_etv_critic    ; save old vector
  159. .endif
  160.  
  161.  
  162. skip1:        clr.w    -(sp)
  163.         move.l    prglen,-(sp)        ; length onto stack
  164.         move.w    #$31,-(sp)        ; for Ptermres()
  165.         trap    #1            ; GEMDOS
  166.  
  167. skip3:        lea    double_err,a0        ; already installed
  168.         bsr    strout
  169.  
  170.         clr.w    -(sp)            ; Pterm0()
  171.         trap    #1            ; GEMDOS
  172.  
  173. ****************************************************************************
  174.  
  175. install:
  176.         move.l    _sysbase,os_start    ; get os_start
  177.  
  178.         tst.l    _p_cookies        ; cookie-jar already alive ?
  179.         bne    in_skip1         ; yes -> go on
  180.         bsr    inst_cookie        ; no -> install the jar
  181.  
  182. in_skip1:    movea.l _p_cookies,a0        ; get cookie-jar base
  183.         moveq    #1,d0            ; clear counter
  184. cookloop:    tst.l    (a0)            ; free entry ?
  185.         beq    cookexit        ; yes -> install cookie id
  186.         cmpi.l    #XBRA_ID,(a0)        ; LTMF alread installed ?
  187.         beq    already_in        ; yes -> quit
  188.         addq.l    #8,a0
  189.         addq.l    #1,d0
  190.         bne    cookloop        ; no -> next
  191. cookexit:    cmp.l    4(a0),d0        ; cookie-jar full ?
  192.         bne    cookskip        ; no -> install it
  193.         bsr    copycookie        ; copy cookie-jar
  194. cookskip:    move.l    (a0),8(a0)        ; copy last cookie
  195.         move.l    4(a0),12(a0)
  196.         move.l    #XBRA_ID,(a0)+        ; cookie id
  197.         move.l    #letemfly,(a0)        ; adress of structure
  198.  
  199.         tst.w    $059e            ; set stackcorr
  200.         beq    in_skip2
  201.         move.l    #8,stackcorr        ; no 68000
  202.         bra    in_ok
  203. in_skip2:    move.l    #6,stackcorr        ; only a 68000
  204.  
  205. in_ok:        moveq    #0,d0            ; o.k.
  206.         rts
  207.  
  208. already_in:    moveq    #-1,d0            ; error
  209.         rts
  210.  
  211. ****************************************************************************
  212. *    install cookie-jar
  213. ****************************************************************************
  214.  
  215. inst_cookie:
  216.         lea    cookiejar,a0
  217.         move.l    a0,_p_cookies        ; adress to _p_cookies
  218.         clr.l    (a0)+            ; make 'last cookie'
  219.         move.l    #MAXCOOKIE,(a0)
  220.  
  221.         move.l    _resvalid,old_rvalid    ; install new reset-routine
  222.         move.l    #RESMAGIC,_resvalid
  223.         move.l    _resvector,old_reset
  224.         move.l    #new_reset,_resvector
  225.  
  226.         rts
  227.  
  228. ****************************************************************************
  229. *    copy cookie-jar
  230. ****************************************************************************
  231.  
  232. copycookie:
  233.         movea.l _p_cookies.w,a1       ; save old address
  234.         bsr    inst_cookie          ; install new cookie-jar
  235.         movea.l _p_cookies.w,a0       ; get new address
  236. cpcook_loop:    move.l    (a1)+,(a0)+          ; copy cookie
  237.         move.l    (a1)+,(a0)+
  238.         tst.l    (a1)              ; last cookie ?
  239.         bne    cpcook_loop          ; no -> next cookie
  240.         clr.l    (a0)               ; make 'last cookie'
  241.         move.l    #MAXCOOKIE,4(a0)
  242.         rts
  243.  
  244. *******************************************************************************
  245. *     new reset routine (deletes the cookie jar)
  246. *******************************************************************************
  247.  
  248.         dc.b    'XBRA'
  249.         dc.l    XBRA_ID
  250. old_reset:    dc.l    0
  251.  
  252. new_reset:    clr.l    _p_cookies        ; clear cookie-jar
  253.         move.l    old_reset,_resvector
  254.         move.l    old_rvalid,_resvalid
  255.         jmp    (a6)
  256.  
  257. ****************************************************************************
  258. *    vq_aes
  259. ****************************************************************************
  260.  
  261. vq_aes:
  262.         move.w    #$0a,d0            ; appl_init()
  263.         jsr    aes
  264.         move.w    global,d0        ; is GEM out there?
  265.         rts
  266.  
  267. ****************************************************************************
  268. *    strout
  269. ****************************************************************************
  270.  
  271. strout:        tst.w    gem_inst
  272.         bne    strout_exit
  273.         move.l    a0,-(sp)        ; string
  274.         move.w    #9,-(sp)        ; Cconws()
  275.         trap    #1            ; GEMDOS
  276.         addq.l    #6,sp
  277. strout_exit:    rts
  278.  
  279. ****************************************************************************
  280. ****************************************************************************
  281.  
  282. ****************************************************************************
  283. *    new TRAP #2 (AES/VDI)
  284. ****************************************************************************
  285.  
  286.         dc.b    'XBRA'
  287.         dc.l    XBRA_ID
  288. old_trap2:    dc.l    0
  289.  
  290. new_trap2:
  291.         movem.l    d2-d3/a1-a3,-(sp)    ; save regs
  292.         cmpi.w    #$c8,d0            ; AES Call ?
  293.         bne    ntrp2_bypass        ; no -> go to end
  294.  
  295.         movea.l    d1,a2            ; AES parameter block
  296.         movea.l    (a2),a1            ; get contrl
  297.         move.w    (a1),d2            ; get func. no.
  298.  
  299.         btst    #CFG_BYPASS,ltmf_config+1    ; BYPASS set ?
  300.         beq    ntrp2_skip        ; no -> skip
  301.         tst.w    jacks_in        ; second call ?
  302.         bne    ntrp2_bypass        ; yes -> bypass
  303.         cmpi.w    #19,d2            ; appl_exit ?
  304.         bne    ntrp2_bypass        ; no -> go to end
  305.         move.l    #ap_exit,aes_jump    ; save adress
  306.         bra    my_aes            ; and go
  307.  
  308. ntrp2_skip:    tst.w    jacks_in        ; second call ?
  309.         bne    ntrp2_bypass        ; yes -> cancel
  310. ;        bne    nt2_skp1        ; yes -> check grow/shrink
  311.  
  312.         lea    aes_tab,a3        ; get tab base
  313.         moveq.l    #0,d3            ; clear counter
  314. nt2_loop:    tst.w    (a3,d3.w)        ; end of table ?
  315.         beq    nt2_skp1        ; yes -> cancel
  316.         cmp.w    (a3,d3.w),d2        ; = function no. ?
  317.         beq    nt2_skp2        ; yes -> go for it
  318.         addq.w    #6,d3            ; next entry
  319.         bra    nt2_loop        ; and go
  320.  
  321. nt2_skp2:    move.l    2(a3,d3.w),aes_jump    ; save adress
  322.         bra    my_aes
  323.  
  324. nt2_skp1:    cmpi.w    #42,d2            ; objc_draw ?
  325.         beq    ob_draw
  326.         cmpi.w    #43,d2            ; objc_find ?
  327.         beq    ob_find
  328.         cmpi.w    #73,d2            ; graf_growbox ?
  329.         beq    gr_grow
  330.         cmpi.w    #74,d2            ; graf_shrinkbox ?
  331.         beq    gr_shrink
  332.         cmpi.w    #77,d2            ; graf_handle ?
  333.         beq    gr_handle
  334.         cmpi.w    #78,d2            ; graf_mouse ?
  335.         beq    gr_mouse
  336.         cmpi.w    #10,d2            ; appl_init() ?
  337.         beq    ap_init
  338.         cmpi.w    #30,d2            ; menu_bar() ?
  339.         beq    mn_bar
  340.         cmpi.w    #34,d2            ; menu_text() ?
  341.         beq    mn_text
  342.  
  343. ntrp2_bypass:    movem.l    (sp)+,d2-d3/a1-a3    ; restore regs
  344.         move.l    old_trap2(pc),-(sp)    ; old routine onto stack
  345.         rts
  346.  
  347. ****************************************************************************
  348.  
  349. aes_tab:    dc.w    50
  350.         dc.l    fm_do
  351.         dc.w    51
  352.         dc.l    fm_dial
  353. .iff LIGHT
  354.         dc.w    52
  355.         dc.l    fm_alert
  356.         dc.w    53
  357.         dc.l    fm_error
  358. .endif
  359.         dc.w    54
  360.         dc.l    fm_center
  361.         dc.w    55
  362.         dc.l    fm_keybd
  363.         dc.w    56
  364.         dc.l    fm_button
  365.         dc.w    46
  366.         dc.l    ob_edit
  367.         dc.w    19
  368.         dc.l    ap_exit
  369.         dc.w    0
  370.  
  371. ****************************************************************************
  372.  
  373. my_aes:
  374.         movem.l    (sp)+,d2-d3/a1-a3    ; restore regs
  375.         move.w    (sp)+,d0        ; save SR from TRAP
  376.         move.l    (sp)+,ret_sav        ; save return adress
  377.         pea    do_aes            ; push my routine
  378.         move.w    d0,-(sp)        ; SR back onto stack
  379.         rte
  380.  
  381. do_aes:
  382.         move.w    #1,jacks_in        ; we are here
  383.         move.l    a0,tempsave        ; save A0
  384.         move.l    sp,a0            ; get stack pointer
  385.         move.l    #my_stack-4,sp        ; install new stack
  386.         move.l    a0,-(sp)        ; save stack pointer
  387.         movem.l    d1-d7/a1-a6,-(sp)    ; save regs
  388.         move.l    d1,a2            ; AES Parameter Block
  389.         move.l    aes_jump,a1        ; get adress
  390.         jsr    (a1)            ; jump to routine
  391.  
  392.         move.l    12(a2),a0        ; int_out
  393.         move.w    d0,(a0)            ; put result
  394.  
  395.         clr.w    jacks_in        ; now we'll go
  396.  
  397.         movem.l    (sp)+,d1-d7/a1-a6    ; restore regs
  398.         move.l    (sp)+,sp        ; restore stack pointer
  399.         move.l    tempsave,a0        ; restore A0
  400.         move.l    ret_sav,-(sp)        ; return adress and go
  401.         rts
  402.  
  403. ****************************************************************************
  404.  
  405. fm_do:
  406.         movea.l    8(a2),a3        ; int_in
  407.         move.w    (a3),d0            ;  start_obj
  408.         movea.l    16(a2),a3        ; addr_in
  409.         movea.l    (a3),a0            ;  *tree
  410.         jmp    nfm_do(pc)        ; go for it
  411.  
  412. ****************************************************************************
  413.  
  414. fm_dial:        
  415.         movea.l    8(a2),a3        ; int_in
  416.         move.w    16(a3),-(sp)        ;  h
  417.         move.w    14(a3),-(sp)        ;  w
  418.         move.w    12(a3),-(sp)        ;  y
  419.         move.w    10(a3),-(sp)        ;  x
  420.         move.w    8(a3),-(sp)        ;  hs
  421.         move.w    6(a3),-(sp)        ;  ws
  422.         move.w    4(a3),d2        ;  ys
  423.         move.w    2(a3),d1        ;  xs
  424.         move.w    (a3),d0            ;  flag
  425.         jsr    nfm_dial(pc)        ; go for it
  426.         lea    12(sp),sp
  427.         rts
  428.  
  429. ****************************************************************************
  430.  
  431. .iff LIGHT
  432.  
  433. fm_alert:
  434.         movea.l    8(a2),a3        ; int_in
  435.         move.w    (a3),d0            ;  button
  436.         movea.l    16(a2),a3        ; addr_in
  437.         movea.l    (a3),a0            ;  *string
  438.         jmp    nfm_alert(pc)        ; go for it
  439.  
  440. ****************************************************************************
  441.  
  442. fm_error:
  443.         movea.l    8(a2),a3        ; int_in
  444.         move.w    (a3),d0            ;  error no.
  445.         jmp    nfm_error(pc)        ; go for it
  446.  
  447. .endif
  448.  
  449. ****************************************************************************
  450.  
  451. fm_center:
  452.         movea.l    12(a2),a3        ; int_out
  453.         pea    8(a3)            ;  fo_ch
  454.         pea    6(a3)            ;  fo_cw
  455.         pea    4(a3)            ;  fo_cy
  456.         lea    2(a3),a1        ;  fo_cx
  457.         movea.l    16(a2),a3        ; addr_in
  458.         movea.l    (a3),a0            ;  *tree
  459.         jsr    nfm_center(pc)        ; go for it
  460.         lea    12(sp),sp
  461.         rts
  462.  
  463. ****************************************************************************
  464.  
  465. fm_keybd:
  466.         movea.l    12(a2),a3        ; int_out
  467.         lea    2(a3),a1        ;  pchar
  468.         pea    4(a3)            ;  pnxt_obj
  469.         movea.l    8(a2),a3        ; int_in
  470.         move.w    2(a3),d2        ;  char
  471.         move.w    4(a3),d1        ;  next_obj
  472.         move.w    (a3),d0            ;  obj
  473.         movea.l    16(a2),a3        ; addr_in
  474.         movea.l    (a3),a0            ;  *tree
  475.         jsr    nfm_keybd(pc)        ; go for it
  476.         addq.l    #4,sp
  477.         rts
  478.  
  479. ****************************************************************************
  480.  
  481. fm_button:
  482.         movea.l    12(a2),a3        ; int_out
  483.         lea    2(a3),a1        ;  pnxt_obj
  484.         movea.l    8(a2),a3        ; int_in
  485.         move.w    2(a3),d1        ;  clicks
  486.         move.w    (a3),d0            ;  obj
  487.         movea.l    16(a2),a3        ; addr_in
  488.         movea.l    (a3),a0            ;  *tree
  489.         jmp    nfm_button(pc)        ; go for it
  490.  
  491. ****************************************************************************
  492.  
  493. ob_edit:
  494.         movea.l    8(a2),a3        ; int_in
  495.         move.w    4(a3),d3        ;  idx
  496.         move.w    6(a3),d2        ;  kind
  497.         move.w    2(a3),d1        ;  char
  498.         move.w    (a3),d0            ;  obj
  499.         movea.l    12(a2),a3        ; int_out
  500.         lea    2(a3),a1        ;  *idx
  501.         move.w    d3,(a1)            ; put idx
  502.         movea.l    16(a2),a3        ; addr_in
  503.         movea.l    (a3),a0            ;  *tree
  504.         jmp    nob_edit(pc)        ; go for it
  505.  
  506. ****************************************************************************
  507.  
  508. ap_init:
  509. ;        tst.w    aes_version        ; already checked?
  510. ;        bne    ntrp2_bypass        ; no -> quit
  511.  
  512.         move.w    #1,jacks_in        ; we are here
  513.         move.l    4(a2),global_base
  514.         movem.l    (sp)+,d2-d3/a1-a3    ; restore regs
  515.         move.w    (sp)+,tempsave
  516.         move.l    (sp)+,ret_sav        ; save return adress
  517.         pea    get_global        ; my return adress
  518.         move.w    tempsave,-(sp)
  519.         move.l    old_trap2(pc),-(sp)    ; old routine onto stack
  520.         rts
  521.  
  522. get_global:
  523.         movem.l    a0-a1/d2,-(sp)        ; save regs
  524.         move.l    global_base,a0        ; global
  525.         lea    global,a1        ; my global
  526. /*        moveq    #6,d2            ; load counter
  527. api_loop:    move.l    (a0)+,(a1)+        ; copy global field
  528.         dbra    d2,api_loop        ; next one
  529.         move.w    (a0),(a1)        ; copy last word
  530. */
  531.         tst.w    (a0)
  532.         beq    api_skip
  533.         move.w    (a0),(a1)        ; copy global[0]
  534.         move.w    (a0),aes_version
  535. api_skip:    movem.l    (sp)+,a0-a1/d2        ; restore regs
  536.         move.l    ret_sav,-(sp)
  537.         clr.w    jacks_in
  538.         rts
  539.  
  540. ****************************************************************************
  541.  
  542. ap_exit:
  543.         jmp    nap_exit(pc)        ; go for it
  544.  
  545. ****************************************************************************
  546.  
  547. ob_draw:
  548.         movea.l    8(a2),a1        ; int_in
  549.         cmpi.w    #1,(a1)
  550.         beq    draw_menu
  551.         tst.w    (a1)            ;  test obj   ROOT ?
  552.         bne    ntrp2_bypass        ; no -> cancel
  553.         movea.l    16(a2),a1        ; addr_in
  554.         move.l    (a1),lasttree        ;  save tree
  555.         clr.l    lastdone        ; clear lastdone
  556.         move.w    #1,was_used
  557.         bra    ntrp2_bypass
  558.  
  559. draw_menu:
  560.         btst    #CFG_NICELN,ltmf_config    ; NICELN set ?
  561.         beq    ntrp2_bypass        ; no -> quit
  562.         movea.l    16(a2),a1        ; addr_in
  563.         movea.l    (a1),a1            ;  tree
  564.         cmpi.w    #32,78(a1)        ; G_TITLE ?
  565.         bne    ntrp2_bypass        ; no -> leave
  566.         movem.l    d0-a6,-(sp)        ; save regs
  567.         movea.l    a1,a0
  568.         move.w    #1,d0
  569.         jsr    menu_patch
  570.         movem.l    (sp)+,d0-a6        ; restore regs
  571.         bra    ntrp2_bypass
  572.  
  573. ****************************************************************************
  574.  
  575. ob_find:
  576.         movea.l    16(a2),a1        ; addr_in
  577.         move.l    (a1),a1            ;  tree
  578.         cmpa.l    lasttree,a1        ; tree == lasttree ?
  579.         bne    ntrp2_bypass        ; no -> leave
  580.         clr.l    lasttree        ; clear lasttree
  581.         bra    ntrp2_bypass        ; and leave
  582.  
  583. ****************************************************************************
  584.  
  585. gr_grow:
  586. gr_shrink:
  587.         btst    #CFG_G_GROW,ltmf_config+1    ; G_GROW set ?
  588.         bne    ntrp2_bypass        ; yes -> do it
  589.         moveq.l    #1,d0            ; no -> cancel
  590.         move.l    12(a2),a0        ; int_out
  591.         move.w    d0,(a0)            ; put result
  592.         movem.l    (sp)+,d2-d3/a1-a3    ; restore regs
  593.         rte
  594.  
  595. ****************************************************************************
  596.  
  597. gr_handle:
  598.         move.w    #1,jacks_in        ; we are here
  599.         move.l    12(a2),intout_base
  600.         movem.l    (sp)+,d2-d3/a1-a3    ; restore regs
  601.         move.w    (sp)+,tempsave
  602.         move.l    (sp)+,ret_sav        ; save return adress
  603.         pea    get_handle        ; my return adress
  604.         move.w    tempsave,-(sp)
  605.         move.l    old_trap2(pc),-(sp)    ; old routine onto stack
  606.         rts
  607.  
  608. get_handle:
  609.         move.l    a0,tempsave        ; save A0
  610.         move.l    intout_base,a0        ; int_out
  611.         move.w    (a0),nl_handle        ; put result
  612.         move.l    tempsave,a0        ; restore A0
  613.         move.l    ret_sav,-(sp)
  614.         clr.w    jacks_in
  615.         rts
  616.  
  617. ****************************************************************************
  618.  
  619. gr_mouse:
  620.         movea.l    8(a2),a1        ; int_in
  621.         cmpi.w    #256,(a1)        ;  M_OFF ?
  622.         bne    grm_skip1        ; no -> next
  623.         sub.w    #1,mousecnt        ; decrease mouse counter
  624.         bra    ntrp2_bypass        ; and leave
  625. grm_skip1:    cmpi.w    #257,(a1)        ;  M_ON ?
  626.         bne    ntrp2_bypass        ; no -> next
  627.         add.w    #1,mousecnt        ; increase mouse counter
  628.         bra    ntrp2_bypass        ; and leave
  629.  
  630. ****************************************************************************
  631.  
  632. mn_bar:
  633. ;        btst    #CFG_NICELN,ltmf_config    ; NICELN set ?
  634. ;        beq    ntrp2_bypass        ; no -> quit
  635.         move.w    #1,jacks_in
  636.         movem.l    d0-a6,-(sp)        ; save regs
  637.         move.l    8(a2),a3        ; int_in
  638.         move.w    (a3),d0            ;  showit
  639.         move.l    16(a2),a3        ; addr_in
  640.         move.l    (a3),a0            ;  tree
  641.         jsr    menu_patch        ; patch the menu
  642.         movem.l    (sp)+,d0-a6        ; restore regs
  643.         clr.w    jacks_in
  644.         bra    ntrp2_bypass        ; and leave
  645.  
  646. ****************************************************************************
  647.  
  648. mn_text:
  649.         move.l    16(a2),a3        ; addr_in
  650.         move.l    (a3),a1            ;  tree
  651.         move.l    8(a2),a3        ; int_in
  652.         moveq    #0,d3
  653.         move.w    (a3),d3            ;  obj
  654.         mulu.w    #24,d3            ; * sizeof(OBJECT)
  655.         adda.l    d3,a1            ; new adress
  656.         cmpi.b    #24,7(a1)        ; G_USERDEF ?
  657.         bne    ntrp2_bypass
  658.         cmpi.l    #niceline,12(a1)    ; niceline ?
  659.         bne    ntrp2_bypass
  660.         move.l    12(a2),a3        ; int_out
  661.         move.w    #1,(a3)            ; put result
  662.         movem.l    (sp)+,d2-d3/a1-a3    ; restore regs
  663.         rte
  664.  
  665. ****************************************************************************
  666. *    new TRAP #13 (BIOS)
  667. ****************************************************************************
  668.  
  669.         dc.b    'XBRA'
  670.         dc.l    XBRA_ID
  671. old_trap13:    dc.l    0
  672.  
  673. new_trap13:
  674.         btst.b    #5,(sp)            ; supervisor ?
  675.         beq    ntrp13_end        ; no -> quit
  676.         move.l    sp,a0
  677.         adda.l    stackcorr(pc),a0
  678.  
  679.         cmpi.l    #$00050101,(a0)        ; Setexc(101, ...) ?
  680.         bne    ntrp13_end        ; no -> skip
  681.  
  682. .if ETV_CRITIC
  683.         tst.l    magx            ; Mag!X out there?
  684.         beq    ntrp13_skip        ; no -> skip this
  685.         move.l    4(a0),a1        ; get pointer
  686.         cmpa.l    os_start(pc),a1        ; points into OS?
  687.         blt    ntrp13_skip        ; no -> skip
  688.         move.l    #new_etv_critic,4(a0)    ; take my critic-handler
  689.         move.l    a1,old_etv_critic    ; save old adress
  690.  
  691. .endif
  692.  
  693. ntrp13_skip:    movea.l    trap2v,a0        ; get TRAP #2
  694. ntrp13_loop:    cmpi.l    #'XBRA',-12(a0)        ; XBRA ?
  695.         bne    ntrp13_set        ; no -> install handler
  696.         cmpi.l    #XBRA_ID,-8(a0)        ; LTMF id ?
  697.         beq    ntrp13_end        ; yes -> already there
  698.         movea.l    -4(a0),a0        ; get next
  699.         bra    ntrp13_loop        ; and check it
  700. ntrp13_set:    move.l    trap2v,old_trap2    ; save old adress
  701.         move.l    #new_trap2,trap2v    ; set new adress
  702.         move.w    #1,gem_inst        ; now installed
  703.  
  704. ntrp13_end:    move.l    old_trap13,-(sp)    ; old_routine
  705.         rts
  706.  
  707. ****************************************************************************
  708. *    new etc_critic handler
  709. ****************************************************************************
  710.  
  711. .if ETV_CRITIC
  712.  
  713.         dc.b    'XBRA'
  714.         dc.l    XBRA_ID
  715. old_etv_critic:    dc.l    0
  716.  
  717. new_etv_critic:
  718.         btst    #CFG_BYPASS,ltmf_config+1    ; BYPASS set ?
  719.         bne    etv_quit        ; no -> quit
  720.         btst    #CFG_ALERT,ltmf_config+1    ; CFG_ALERT set ?
  721.         beq    etv_quit        ; no -> cancel
  722.         tst.l    magx            ; Mag!X ?
  723.         bne    etv_skip        ; yes -> go for it
  724. /*        cmpi.w    #$0400,global        ; AES >= 4.0 ?
  725.         bge    etv_skip        ; yes -> go for it
  726. */
  727. etv_quit:    move.l    old_etv_critic,-(sp)    ; old vector onto stack
  728.         rts
  729.  
  730. etv_skip:    move.w    4(sp),d0        ; errno
  731.         move.w    6(sp),d1        ; driveno
  732.  
  733.         move.l    sp,a0            ; get ssp
  734.         move.l    #my_ssp-4,sp        ; install new ssp
  735.         move.l    a0,-(sp)        ; save old ssp
  736.         move.l    usp,a0            ; get usp
  737.         move.l    a0,-(sp)        ; save usp
  738.         move.l    #my_stack-4,a0        ; install new usp
  739.         move.l    a0,usp
  740.  
  741.         movem.l    d3-d7/a3-a6,-(sp)    ; save regs
  742.         move.w    #1,jacks_in
  743.         jsr    netv_critic        ; and go ...
  744.         clr.w    jacks_in
  745.         movem.l    (sp)+,d3-d7/a3-a6    ; restore regs
  746.  
  747.         move.l    (sp)+,a0        ; restore usp
  748.         move.l    a0,usp
  749.         move.l    (sp)+,sp        ; restore ssp
  750.         rts
  751.  
  752. .endif
  753.  
  754. ****************************************************************************
  755.  
  756.         even
  757.  
  758. os_start:    ds.l    1
  759. old_rvalid:    ds.l    1
  760. stackcorr:    ds.l    1
  761.  
  762. aes_jump:    ds.l    1
  763.  
  764. gem_inst:    dc.w    0
  765.  
  766. tempsave:    ds.l    1
  767. ret_sav:    ds.l    1
  768. savssp:        ds.l    1
  769. savusp:        ds.l    1
  770.  
  771. mousecnt:    dc.w    1
  772.  
  773. etv_err:    ds.l    1
  774. etv_drive:    ds.w    1
  775.  
  776. intout_base:    ds.l    1
  777. global_base:    ds.l    1
  778.  
  779. ****************************************************************************
  780.  
  781.         data
  782.  
  783. multi_aes:    dc.l    0
  784. magx:        dc.l    0
  785. aes_version:    dc.w    0
  786.  
  787. prgstart:    dc.l    0
  788. prglen:     dc.l    0
  789.  
  790. jacks_in:    dc.w    0
  791.  
  792.  
  793. patch_dummy:    dc.b    'PATCH:'
  794.  
  795. letemfly:
  796. ltmf_version:    dc.w    $0120
  797. .if LIGHT
  798. ;             ln-tvckertfamggb
  799. ltmf_config:    dc.w    %1101101100100010
  800. .else
  801. ;             lnjtvckertfamggb
  802. ltmf_config:    dc.w    %0110101101110010
  803. .endif
  804. ltmf_path:    dc.l    0
  805. ltmf_di_fly:    dc.l    di_fly
  806. ltmf_obj_clsiz:    dc.l    obj_clsize
  807. ltmf_do_key:    dc.l    0
  808. ltmf_init_keys:    dc.l    init_keys
  809. ltmf_look_key:    dc.l    lookup_key
  810. ltmf_di_moveto:    dc.l    di_moveto
  811. ltmf_di_center:    dc.l    di_center
  812. ltmf_ucol:    dc.w    2
  813. ltmf_aicol:    dc.w    2
  814. ltmf_aframe:    dc.w    1
  815. ltmf_flydelay:    dc.w    3
  816. ltmf_hist_ins:    dc.l    hist_insert
  817. ltmf_ins_spcch:    dc.l    ins_spcchar
  818. ltmf_init_ncln:    dc.l    init_niceline
  819.  
  820.  
  821. rvs_on:        dc.b    10,27,"p ",0
  822. rvs_off:    dc.b    " ",27,"q",13,10," ",0
  823. freaky:        dc.b    13,10," ... this software goes Freaky Deaky!",13,10,0
  824.  
  825. .iff LIGHT
  826. ld_icons:    dc.b    "(loaded new icons)",13,10,0
  827. .endif
  828.  
  829. double_err:    DC.B    "already installed!",13,10,10,0
  830.  
  831. ****************************************************************************
  832.  
  833.         bss
  834.  
  835. cookiejar:    ds.l    MAXCOOKIE * 2
  836.  
  837.         ds.b    2048
  838. my_stack:
  839.         ds.b    1024
  840. my_ssp:
  841.         end
  842.